<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>过滤器</title>
    <script type="text/javascript" src="vue.js"></script>
</head>
<body>
    <div id="root">
        <input type="text" v-model="msg1">
        <h1>{{msg1 | filterA}}</h1>
        <input type="text" v-model="msg2">
        <h1>{{msg2 | filterB}}</h1>
    </div>
</body>
<script>
    Vue.config.productionTip = false
    var vue=new Vue({
        el:"#root",
        data() {
            return {
                msg1:'',
                msg2:''
            }
        },
        filters:{
            filterA(value){
                return value.split(" ").join("")    
            },
            filterB(value){
                return  parseFloat(value).toFixed(2)+"元"
            }
        }
    })
</script>
</html>